package com.eric.flowabledemo.controller;

import com.eric.flowabledemo.model.request.ProcessRequestData;
import com.eric.flowabledemo.model.response.ResponseResult;
import com.eric.flowabledemo.service.RmaProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "/rma", produces = MediaType.APPLICATION_JSON_VALUE)
public class RmaProcessController {

    @Autowired
    private RmaProcessService rmaProcessService;

    /**
     * 开单
     * @return
     */
    @PostMapping(value = "/create")
    public ResponseResult createRma(){
        return rmaProcessService.createRma();
    }

    /**
     * 下一步
     * @param businessKey
     * @return
     */
    @PostMapping(value = "/nextstep/{businessKey}")
    public ResponseResult nextStep(@PathVariable("businessKey") String businessKey){
        //封装请求参数
        Map<String, Object> variableParams = new HashMap<>();
        variableParams.put("rmaCenter", "2132");
        ProcessRequestData data = new ProcessRequestData(businessKey, variableParams);
        //下一步
        return rmaProcessService.nextStep(data);
    }
}
